#!/bin/sh
set -e

REDISPORT=6379
PASSWORD="admin123"
EXEC="/Users/ankang/develop/redis-5.0.7/src/redis-server"
CLIEXEC="/Users/ankang/develop/redis-5.0.7/src/redis-cli"
CONF="/Users/ankang/develop/redis-demo/standalone/conf/redis-${REDISPORT}.conf"

case "$1" in
    start)
        echo "Starting Redis server..."
        $EXEC $CONF
        ;;
    stop)
        echo "Stopping ..."
        $CLIEXEC -p $REDISPORT -a $PASSWORD shutdown
        echo "Waiting for Redis to shutdown ..."
        sleep 2
        echo "Redis stopped"
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac
